$title Stylized Johansen model

* -----------------------------------------------------------------------------------
* Model from Chapter 3 of the text "Notes and Problems in Applied General Equilibrium
* Economics" by Dixon, Parmenter, Powell and Wilcoxen (1992).
* Laurent Cretegny, CoPS, Monash University, Australia, 2004.
* -----------------------------------------------------------------------------------

sets
  sect              sectors
  fac               factors;

alias (good,sect);

parameters
  qcomin(good,sect) inputs quantity of commodity good to industry sect
  qfacin(fac,sect)  quantity of factor fac used in industry sect
  qhous(sect)       quantity of household use of commodity good
  endow(fac)        total demand for (or supply of) factor fac;

$gdxin sjmge
$load sect fac qcomin qfacin qhous
$gdxin

endow(fac) = sum(sect, qfacin(fac,sect));

$ontext
$model:sjmge

$sectors:
  xcom(sect)        ! production
  w                 ! welfare

$commodities:
  pc(sect)          ! price of commodity sect
  pf(fac)           ! price of factor fac
  pw                ! consumer price index

$consumers:
  y                 ! total nominal household expenditure

$prod:xcom(sect)    s:1.0
  o:pc(sect)        q:(sum(good, qcomin(good,sect)) + sum(fac, qfacin(fac,sect)))
  i:pc(good)        q:qcomin(good,sect)
  i:pf(fac)         q:qfacin(fac,sect)

$prod:w             s:1.0
  o:pw              q:(sum(sect, qhous(sect)))
  i:pc(sect)        q:qhous(sect)

$demand:y
  d:pw
  e:pf(fac)         q:endow(fac)

$report:
  v:c(sect)         i:pc(sect)          prod:w

$offtext
$sysinclude mpsgeset sjmge

* Benchmark replication

sjmge.iterlim = 0;
$include sjmge.gen
solve sjmge using mcp;
abort$(abs(sjmge.objval) gt 1e-7) "*** sjmge does not calibrate ! ***";
sjmge.iterlim = 1000;

* Fixation of a numeraire to allow comparison

pw.fx = pw.l;

* Counterfactual : 10% increase in labor endowment

endow("labor") = 1.1 * endow("labor");

$include sjmge.gen
solve sjmge using mcp;

* Results

parameters
  res_com           results by commodity in % change from basis
  res_agg           aggregate results in % change from basis; 

res_com("xcom",sect) = (xcom.l(sect) - 1) * 100;
res_com("xh",sect) = (c.l(sect)/qhous(sect) - 1) * 100;
res_com("pc",sect) = (pc.l(sect) - 1) * 100;

res_agg("welfare") = (w.l - 1 ) * 100;
res_agg("cpi") = (pw.l - 1 ) * 100;
res_agg("y") = (y.l/(sum(sect, qhous(sect))) - 1 ) * 100;

option decimals = 6;
display res_com, res_agg;
